home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_537 / chip8 / chip8.doc < prev    next >
Text File  |  1992-05-06  |  12KB  |  294 lines

  1.  
  2.         AMIGA CHIP 8 INTERPRETER & DREAM MON V1.1
  3.         =========================================
  4.  
  5.               (C) PAUL HAYTER 1990,91
  6.  
  7.     Does anyone remember the RCA COSMAC VIP computer ?
  8.     How about the DREAM 6800 or ETI 660 ?
  9.     I'm not surprised if you don't. These were El-Cheapo 
  10. Make-It-Yourself Hobbyist computers which appeared in the early 1980's. The 
  11. COSMAC would be more widely known to U.S. Amiga owners. I'm not exactly 
  12. sure whether you had to construct the COSMAC yourself, but the DREAM and 
  13. ETI 660 both appeared in Australian Electronics Magazines as construction 
  14. projects. What all these computers had in common was that they were 
  15. disgustingly cheap (about $100), used a hex keypad, could produce ultra 
  16. stingy 64 x 32 PIXEL (The ETI 660 had 64 x 48 OR 64 x 64 with a 
  17. modification) graphics for display on a TV, had about ONE kilobyte of RAM, 
  18. and all ran a pseudo high-level language called CHIP 8 (which was developed 
  19. by RCA for showing off the COSMAC's graphics, I think).
  20.  
  21.     Somewhere along the way, my older brother made up a DREAM 6800. 
  22. What a computer! Along with the construction articles for the DREAM & ETI 
  23. 660 were heaps of CHIP 8 game listings. Some of the games were only 200 
  24. BYTES or so, so it didn't take forever to type them in. And the games were 
  25. great fun. They weren't slow. And CHIP 8 was pretty much designed for 
  26. making Classic style TV games anyway.
  27.  
  28.     Alas, the DREAM is now resting silently covered in dust. Even 
  29. though I now have an Amiga, I somehow yearned to play those hopelessly 
  30. simple games on the DREAM again. So I've made a CHIP 8 interpreter for the 
  31. Amiga with a monitor interface (pretty much) identical to the monitor in 
  32. the DREAM 6800.
  33.  
  34. DREAM MON
  35. =========
  36.     CHIP 8 can be started from Workbench or CLI. If from the CLI then
  37.  
  38. 1> chip8
  39.  
  40.     Otherwise double click on its icon.
  41.  
  42.     You start up in the DREAM monitor environment. The screen is all 
  43. black except for a white bar across the middle. The white bar shows the 
  44. current 4 digit HEX ADDR followed by the HEX byte contents of that memory 
  45. location (NB: these do not correspond to actual Amiga addresses). CHIP 8 in 
  46. its original form only allowed addressing of a 4Kbyte block of RAM. My 
  47. implementation does the same, so addresses 0000 thru 0FFF are the only 
  48. valid ones. The DREAM MON has the following commands:
  49.  
  50.     RETURN,=,SPACE,+       :Advance the hex address by 1.
  51.     -,BACKSPACE           :Decrement the hex address by 1.
  52.     M               :Once you hit M you can type in a new
  53.                 4 digit hex address.
  54.     G               :Executes the CHIP 8 program from the
  55.                 current location.
  56.     L               :Loads a CHIP 8 source (?) file from disk.
  57.                 A file requester appears, so that you can
  58.                 can select a chip8 source file (*.c8).
  59.     S               :Saves a compressed file holding the entire
  60.                 4K CHIP8 workspace. Again a file requester
  61.                 appears allowing you to enter a new file
  62.                 name, or save as the old name.
  63.     X               :Exit back to the CLI.
  64.     K               :Klears memory.
  65.     Any hex digit           :Typing 2 hex digits in succession will
  66.                 enter that byte into the current location
  67.                 and auto advance the current address.
  68.  
  69. NOTE: DREAM MON starts up pointing to address 0200. This is the default
  70. for a DREAM 6800. All programs written for the DREAM are usually entered
  71. at 0200 onwards. However, programs for the ETI-660 are entered at 0600
  72. onwards.
  73.  
  74. NOTE: CHIP 8 programs are saved by run length encoding the entire 4K
  75. workspace. The compressor works best when the areas of memory which are not
  76. used remain blank (= 00). So it is wise to use the Klear command before
  77. you type a new program in.
  78.  
  79. An important thing to remember is that this monitor is VERY 
  80. UN-USERFRIENDLY. You do not hit return after you enter a line. Nor can you 
  81. correct errors in what you type. However, it is pretty much identical to 
  82. the original DREAM MON.
  83.  
  84. CHIP 8 EMULATOR
  85. ===============
  86.     After you've pressed G , a chip8 program will either end by itself
  87. or stay in an infinite loop. If it is in an infinite loop, then you can
  88. return to the DREAM MON by pressing the left mouse button.
  89.  
  90. CHIP 8
  91. ======
  92.     CHIP 8 is a kind of high level machine code. No one these days can 
  93. beleive that a machine code (the actual hex codes making up each 
  94. instruction) could possibly be "high level", but it is! 
  95.  
  96.     Each instruction in CHIP 8 consists of 4 hex digits (one word). The 
  97. 1st hex digit determines the command to be executed, with the remaining 3 
  98. digits forming the parameters of the command. The designers have tried to
  99. make the first hex digit relate to the command. ie. D for the Display
  100. command. Most instructions either operate on a variable and an immediate
  101. constant or two variables or just one variable.
  102.  
  103.     If we liken CHIP8 to a microprocessor, what we have is a CPU with
  104. a 4K address space, 16 x 1 byte registers V0 to VF, and one 12 bit memory
  105. index pointer called I. You can load immediate with the 6XKK and AMMM
  106. instructions. You can Jump with the 1MMM and BMMM instructions. You
  107. can have subroutines with the 2MMM and 00EE instructions. All your
  108. condition handling is done with the SKF instructions (usually followed
  109. by a GOTO instruction. And the 8XY? instructions allow you to do most
  110. arithmetic on the Variables V0 - VF. You have a sort of INKEY$ (from
  111. BASIC) instruction with the EX9E and EXA1 instructions.
  112.     The most powerful instruction is the DXYN instruction which
  113. allows you to place a software sprite at any X,Y position on the screen.
  114. The image is XORed onto the screen, so you just display it twice to
  115. erase it.
  116.     There are also special instructions to handle numeric output
  117. (i.e. game scores). The FX33 instruction stores 3 bytes in memory starting
  118. at I. The 3 bytes correspond to the 3 decimal digits of VX.
  119. eg.
  120.  
  121.  0200    6AFE    VA=FE    (254 decimal)
  122.  0202    A240    I=240
  123.  0204    FA33    MI=DEQ,V3
  124.  ...
  125.  
  126. This fragment will store 02 in location 240, 05 in location 241, & 04
  127. in location 242. To use this information we use the FX65 instruction which
  128. loads V0 thru VX from memory pointed to by I. For example, continuing the
  129. above program:
  130.  
  131.  0206    F265    V0:V2=MI    {should set V0=02, V1=05, V2=04}
  132.  ...
  133.  
  134. Now, to display this 3 digit number we use the FX29 instruction. This
  135. sets the I pointer to point to a software sprite pattern corresponding
  136. to the least most significant hex digit in VX. Continuing the above:
  137.  
  138.  0208    6410    V4=10
  139.  020A    6508    V5=08
  140.  020C    F029    I=DSP,V0    {I should point to the image of a 2}
  141.  020E    D455    SHOW 5@V4,V5    {show a 2}
  142.  0210    7404    V4=V4+04    {bump X coord}
  143.  0212    F129    I=DSP,V1    {I should point to the image of a 5}
  144.  0214    D455    SHOW 5@V4,V5    {show a 5}
  145.  0216    7404    V4=V4+04    {bump X coord}
  146.  0218    F229    I=DSP,V2    {I should point to the image of a 4}
  147.  021A    D455    SHOW 5@V4,V5    {show a 4}
  148.  021C    F000    STOP
  149.  
  150.     While I won't give a full explanation of how to program in CHIP-8, 
  151. I will give a run down of the commands which my version understands.
  152.  
  153.  CODE    MNEMONIC    DESCRIPTION
  154.  
  155.  1MMM    GOTO MMM    Jump instruction at location MMM
  156.  BMMM    GOTO MMM + V0    Jump to MMM + V0
  157.  2MMM    DO MMM        Do CHIP8 subroutine at location MMM
  158.  00EE    RETURN        Return from CHIP8 subroutine
  159.  3XKK    SKF VX = KK    Skip next instruction if VX=KK
  160.  4XKK    SKF VX <> KK    Skip if VX NOT = KK
  161.  5XY0    SKF VX = VY    Skip if VX = VY
  162.  9XY0    SKF VX <> VY    Skip if VX NOT = VY
  163.  EX9E    SKF VX = KEY    Skip if Key Down = VX; Don't wait
  164.  EXA1    SKF VX <> KEY    Skip if Key Down <> VX; Don't wait
  165.  6XKK    VX = KK        Let Variable X = hex value KK
  166.  CXKK    VX = RND.KK    Get random byte. AND with KK.
  167.  7XKK    VX = VX + KK    Add (2's complement) KK to VX
  168.  8XY0    VX = VY        Let VX = VY
  169.  8XY1    VX = VX!VY    Logical OR VX with VY
  170.  8XY2    VX = VX.VY    Logical AND VX with VY
  171.  8XY3    VX = VX XOR VY    Logical exclusive OR VX with VY
  172.  8XY4    VX = VX + VY    Add VY to VX. If result > FF then VF = 1
  173.  8XY5    VX = VX - VY    Subtract VY. If VX < VY then VF = 0, else 1
  174.  FX07    VX = TIME    Get current timer value
  175.  FX0A    VX = KEY    Input hex keycode (wait for keypress)
  176.  FX15    TIME = VX    Initialise timer; 01 = 20 millisecs
  177.  FX18    TONE = VX    Bleep for 20 x VX millisecs (NOT YET IMPLEMENTED)
  178.  AMMM    I = MMM        Set memory index pointer to MMM
  179.  FX1E    I = I + VX    Add VX to memory pointer
  180.  FX29    I = DSP, VX    Set pointer to show VX (Least significant digit)
  181.  FX33    MI = DEQ, VX    Store 3 digit decimal equivalent of VX
  182.  FX55    MI = V0:VX    Store V0 thru VX at I; I = I + X + 1
  183.  FX65    V0:VX = MI    Load V0 thru VX at I; I = I + X + 1
  184.  00E0    ERASE        Clear screen
  185.  0MMM    CALL MMM    Call machine code at MMM (NOT IMPLEMENTED)
  186.  DXYN    SHOW N @ VX,VY    Display N byte pattern at coord (VX,VY)
  187.  0000    NOP        Do nothing
  188.  F000    STOP        Return to Monitor
  189.  
  190. EXAMPLE PROGRAM
  191. ===============
  192.  
  193.     Just type the hex numbers in at the address shown.
  194.     The following program moves a box diagonally across the screen.
  195.  
  196.  ADDR    BYTES
  197.  
  198.  0200    6A00    VA=00
  199.  0202    6B00    VB=00
  200.  0204    A210    I=210
  201.  0206    DAB7 ->    SHOW 7@VA,VB
  202.  0208    DAB7 |    SHOW 7@VA,VB
  203.  020A    7A02 |    VA=VA+02
  204.  020C    7B01 |    VB=VB+01
  205.  020E    1206 --    GOTO 206
  206.  0210    FF81    DATA FOR BOX
  207.  0212    8181
  208.  0214    8181
  209.  0216    FF
  210.  
  211. GETTING STARTED
  212. ===============
  213.  
  214.     Run CHIP8. You should be presented with a blank screen, with a bar
  215. halfway down showing the address $0200 and its contents. Use the left and
  216. right arrow keys to step you forward/backward thru memory. Try pressing
  217. some hex numbers. You'll only see the first one you type, as the memory
  218. address auto advances after you've entered a byte value into it. You can
  219. step backwards with the left arrow to see what you've entered.
  220.     Try pressing K. This will clear the memory to all zeros, removing
  221. any hex values you may have typed.
  222.     Lets load a game. Press L. A file requester will pop up. If you
  223. are not currently in the Chip8 directory, you will have to click on
  224. a few directories until you arrive. Look at all the files ending in .c8  .
  225. These are chip8 source files. Note that some end in 2.c8  and others end
  226. in  6.c8  .The ones ending in 2.c8 MUST be executed (pressing G) at
  227. address 0200. Conversely the ones ending in 6.c8 must be executed at 0600.
  228.     Try selecting WipeOff2.C8 and clicking OK. Now to run the game, the
  229. memory address on the screen must be 0200. If it is not, type the
  230. following 5 keys:
  231.  
  232.     M  0  2  0  0
  233.  
  234.     To run the game just press G. This is a simple breakout game.
  235. Press keys 4 and 6 to move the bat left and right. If at any time you
  236. want to return to the DREAM monitor, press the left mouse button.
  237.  
  238. IN THIS DIRECTORY
  239. =================
  240.  
  241.  CHIP8            The DREAM monitor and CHIP 8 emulator.
  242.  CHIP8.s        Assembly source for the above.
  243.  CHIP8.doc        This doc file.
  244. The following games are from the original DREAM 6800 article.
  245.  WipeOff2.c8        WipeOff. 4=left,6=right
  246.  UFOIntercept2.c8    UFO Intercept. 4=shoot left,5=shoot middle
  247.             6=shoot right.
  248.  Kaleidescope6.c8    Kaleidescope. Move with 4,6,8,2 keys. 0 to start
  249.  TankBattle6.c8        Tank Battle. Move with 4,6,8,2 keys, 5 =fire
  250.  15puzzle2.c8        15 Puzzle. Use 4,6,8,2 keys to move tiles into
  251.             blank spot.
  252.  ExampleA2.c8        An example program.
  253.  ExampleB2.c8        Another example.
  254.  
  255. NOTE: most chip8 games use the cursor keys on the number pad for direction
  256. control.
  257.  
  258.  
  259. CREDITS
  260. =======
  261.  
  262.  Michael J Bauer for the DREAM 6800 computer (May, June, July, & August
  263. 1979 issues of Electronics Australia).
  264.  Hugh Anderson & Graeme Teesdale for the ETI-660 computer (Mainly the
  265. November 1981 issue of Electronics Today International)
  266.  Whoever designed the RCA COSMAC VIP computer.
  267.  
  268.  Jukka Marin of Supervisor Software for his File Requester (AmigaLibDisk
  269. #247).
  270.  
  271.  
  272.     DISTRIBUTION
  273.     ============
  274.  
  275.         CHIP8 IS FREELY DISTRIBUTABLE. YOU CAN COPY IT AS
  276.     MUCH AS YOU LIKE AS LONG AS THE FOLLOWING IS SATISFIED.
  277.         1. ONLY A NOMINAL COPYING FEE IS CHARGED.
  278.         2. IT IS NOT USED FOR COMMERCIAL PURPOSES.
  279.  
  280.     NOTE: THE DOC FILE MUST BE DISTRIBUTED WITH THE EXECUTABLE. THE
  281.           SOURCE FILES CAN OPTIONALLY BE DISTRIBUTED WITH THESE TOO.
  282.  
  283.     CORRESPONDENCE
  284.     ==============
  285.  
  286.         Please send any bug reports/ or correspondence to myself
  287.     at the address below.
  288.  
  289.         Paul Hayter
  290.         PO BOX 331
  291.         Ballina
  292.         2478
  293.         Australia.
  294.